package com.laizhenghua.share.order.api.factory;

import com.laizhenghua.share.common.core.domain.R;
import com.laizhenghua.share.order.api.RemoteOrderService;
import com.laizhenghua.share.order.api.domain.entity.OrderInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * TODO
 *
 * @Description
 * @Author laizh
 * @Date 2025/10/29 20:07
 **/
@Slf4j
@Component
public class RemoteOrderServiceFallbackFactory implements FallbackFactory<RemoteOrderService> {
    @Override
    public RemoteOrderService create(Throwable cause) {
        log.error("订单服务调用失败: {}", cause.getMessage());
        return new RemoteOrderService() {
            @Override
            public R<OrderInfo> findNotFinishOrder() {
                return R.fail("系统繁忙,请稍后再重试!");
            }

            @Override
            public R<?> create() {
                return R.fail("系统繁忙,请稍后再重试!");
            }
        };
    }
}
